﻿using System;
using System.IO;
using System.Text;
using MakeTableTool.Serialization;
using OfficeOpenXml;
namespace MakeTableTool
{
    public class MakeTable
    {
        public static ExcelTable LoadTable(string path)
        {
            FileInfo file = new FileInfo(path);
            if (file == null)
            {
                Utils.LogMessage("没有找到文件 Path {0}",path);
                return null;
            }
            using (ExcelPackage package = new ExcelPackage(file))
            {
                var workbook = package.Workbook;
                if (workbook.Worksheets.Count == 0)
                    return null;
                ExcelWorksheet worksheet = package.Workbook.Worksheets[1];

              
                ExcelTable table = new ExcelTable(path, worksheet);
                return table;
            }
        }

        public static void SaveFile(ExcelTable table,string savingPath)
        {
            var isSave = FileSaver.SaveFile(table, savingPath);
            Utils.LogMessage("保存数据文件 {0}",Path.GetFileName(savingPath));
        }

       
    }
}

